#install.packages("measurements")
library(ggmap)
library(measurements)
pcs <- read_sf("alldata/Scotland_pcs_2011")
#Print Post codes lists
arransubsect <- filter(pcs,substr(label,1,4)=="KA27")
arransubsect %>%
ggplot() +
geom_sf() +
theme(axis.text.x=element_text(angle=45, hjust = 1))

head(arransubsect)
Simple feature collection with 1 feature and 2 fields
geometry type: MULTIPOLYGON
dimension: XY
bbox: xmin: 186130 ymin: 618830.5 xmax: 206925.5 ymax: 652393
epsg (SRID): NA
proj4string: +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs
name label geometry
1 KA27 8 KA27 8 MULTIPOLYGON(((188338 63101...
ggplot() +
geom_point(data= arrancoordinates, mapping = aes(x = longitude, y = latitude))

ggplot() +
geom_point(data= arrancoord2, mapping = aes(x = longitude, y = latitude))

head(arrancoordinates)
arrancoord2<- arrancoordinates
arrancoord3<- arrancoordinates
library("sp")
?char2dms
# change the space symbol to a degree
arrancoord2$latitude = gsub(' ', '°', arrancoord2$latitude)
arrancoord2$longitude = gsub(' ', '°', arrancoord2$longitude)
# convert from decimal degrees to decimal minutes
arrancoord2$latitude = measurements::conv_unit(arrancoord2$latitude, from = 'dec_deg', to = 'deg_dec_min')
arrancoord2$longitude = measurements::conv_unit(arrancoord2$longitude, from = 'dec_deg', to = 'deg_dec_min')
head(arrancoord2)